import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.zxhtom.utils.HttpClientUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * @package PACKAGE_NAME
 * @Class Blog
 * @Description TODO
 * @Author zhangxinhua
 * @Date 19-9-19 下午3:39
 */
public class Blog {

    public static void main(String[] args) {
        Blog blog = new Blog();
        System.out.println(blog.getJueJinHtmlByUrl("https://juejin.im/post/"+"5d8c261de51d4577ea077e94"));

    }
    public String getJueJinHtmlByUrl(String url) {
        Map<String, String> headMap = new HashMap<>();
        headMap.put("Accept-Language", "zh-Hans,zh;q=0.9");
        String str = HttpClientUtil.getInstance().httpGet(url,headMap);
        Document html = Jsoup.parse(str);
        Elements article = html.select("article");
        Elements imgs = html.select("img");
        for (Element img : imgs) {
            if (img.hasAttr("data-src")) {
                img.attr("src", img.attr("data-src"));
            }
        }
        return article.toString();
    }
}
